
/**
 * Returns whether a room matches the required number of seats
 * 
 * @param room
 * @param numPeople
 * @return
 */
function matchesPeople(room, numPeople) {
	if (numPeople <= 0) {
		return true;
	} else if (room.seats >= numPeople) {
		return true;
	} else {
		return false;
	}
}

/**
 * 
 * @param room
 * @param needProjector
 * @return
 */
function matchesProjector(room, needProjector)
{
	if (!needProjector)
	{
		return true;
	}
	else if (room.projector)
	{
		return true;
	}
	else {
		return false;
	}
}


function matchesComputer(room, needComputer)
{
	if (!needComputer)
	{
		return true;
	}
	else if (room.computer)
	{
		return true;
	}
	else {
		return false;
	}
}

function matchesKeywords(room, keywords)
{
	keywords = $.trim(keywords);
	keywords = keywords.toLowerCase();
	if (!keywords)
	{
		return true;
	}
	else
	{
		keywords = keywords.split(' ');
		var fullText = room.getFullText();
		var result = false;
		for (i = 0; i < keywords.length; ++i)
		{
			var key = keywords[i];
			if (fullText.search(key) < 0)
			{
				return false;
			}
		}
		return true;
	}
}


function matchesBounds(room, bounds)
{
	var bldg;
	var bldg = room.getBldg();
	var location = new GLatLng(bldg.lat, bldg.lng);

	return inBounds(location, bounds);
}

function inBounds(latlng, bounds)
{
	var sw = bounds.getSouthWest();
	var ne = bounds.getNorthEast();
	return (latlng.lat() > sw.lat() && latlng.lat() < ne.lat() &&
			latlng.lng() > sw.lng() && latlng.lng() < ne.lng());
}